package com.camunda.demo.controller;

import org.camunda.bpm.engine.TaskService;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.engine.delegate.JavaDelegate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @author : pengjie
 * @version v1.0.0
 * @ClassName : SmsServiceTask
 * @Description : TODO
 * @email : 627799251@qq.com
 * @Date : 2019/6/27 16:54
 */

@Component
public class SmsServiceTask implements JavaDelegate {
    private static final Logger log = LoggerFactory.getLogger(SmsServiceTask.class);

    private final TaskService taskService;

    public SmsServiceTask(TaskService taskService) {
        this.taskService = taskService;
    }

    @Override
    public void execute(DelegateExecution delegateExecution) throws Exception {
        Map<String, Object> variables = delegateExecution.getVariables();
        log.info("variables is {}", variables);

        String studentId = (String)variables.get("student");
        boolean approved_1 = (boolean)variables.getOrDefault("approved_1", false);
        boolean extra_info_1 = (boolean)variables.getOrDefault("extra_info_1", false);

        log.info("success send sms message to the student {}, approved_1 {}, extra_info_1 {}", studentId, approved_1, extra_info_1);
    }
}